/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-15 16:48:46
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-06 09:02:33
 * @FilePath: \adminstration\src\Common\Modal\TwoModalList\LabReportTemplates.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../Api/Api'
import { TwoAddBtn, ThrDeleteBtn, SeeEnclosure } from '../options'

export const Supervise = async ({ upDataEvent, data }) => {
    let dataList = {
        type: '工序明细',
        hideInSearch: true,
        pageSize: 10,
        params: { SuperviseUuid: data.uuid },
        classification: 'TableModal',
        get: API_LIST()['getSuperviseDetail'],
        options: [
            <TwoAddBtn
                upDataEvent={upDataEvent}
                title="添加明细数据"
                ThrKey="ThrModal"
                value="Supervise"
                data={data}
            />,
        ],
        columns: [
            {
                dataIndex: 'SuperviseUuid',
                title: '主表uuid',
                valueType: 'hidden',
                hidden: true,
                hideInTable: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'uuid',
                title: '编号',
                hidden: true,
                hideInTable: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'tableName',
                title: '附件名称',
                valueType: 'input',
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 300,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { attachment } = record
                    const { fileUrl } = attachment
                    return [
                        fileUrl && (
                            <SeeEnclosure
                                key="see"
                                title="查看附件"
                                data={{
                                    className: 'Admin',
                                    url: fileUrl,
                                }}
                            />
                        ),
                        <ThrDeleteBtn
                            key="delete"
                            record={record.uuid}
                            upDataEvent={upDataEvent}
                            data={{ key: 'delete', url: 'delSuperviseDetail', title: '删除附件信息' }}
                        />,
                    ]
                },
            },
        ],
    }
    return dataList
}
